Script: --on windowEvent wdID,wdName,objNo,objName,objValue¬global gWindowPositions, gYears, kMaxPeriods¬¬---------------------¬-- This is window #26¬---------------------¬¬if objValue="Open" then ¬ -- Restore old window position¬ put OldWindowPosition(26) into windowRect¬ if windowRect = empty then centerWindow wdName¬ else wsSet wdID,"0","Rect",windowRect¬ ¬ -- Set up fields for first time¬ put (the number of lines of gYears >= kMaxPeriods) into disableStartNew¬ ¬ get "CurrentPeriod_Disabled:True" & return & "currentPeriod_Text:" & return & "i3_disabled:" & disableStartNew & return & "i4_Disabled:True" & return¬ set the properties of window wdName to it¬ set "TimePeriods_Text" of window wdName to gYears¬ if there is a menuItem "Close" of menu "File" then¬ enable menuItem "Close" of menu "File"¬ end if¬ ¬else if objValue="Close" then ¬ -- save the window position¬ get wsGet(wdID,"0","Rect")¬ put "26" & tab & wdName & tab & it into line 26 of gWindowPositions¬ if there is a menuItem "Close" of menu "File" then¬ disable menuItem "Close" of menu "File"¬ end if¬ ¬ put wsGet(wdID,"TimePeriods","Text") into gYears¬else if objValue="Suspend" then ¬ put frontWindow() into theFrontID¬ if wsGet(theFrontID,"0","HasCloseBox") <> "True" then¬ if there is a menuItem "Close" of menu "File" then¬ disable menuItem "Close" of menu "File"¬ end if¬ end if¬ ¬else if objValue="Resume" then ¬ if there is a menuItem "Close" of menu "File" then¬ enable menuItem "Close" of menu "File"¬ end if¬ ¬else if objValue="CloseBox" then ¬ ¬else if objValue="ZoomBox" then ¬ ¬else if objValue="GrowBox" then ¬ ¬else if objValue="TitleBar" then ¬ ¬end if¬¬--end windowEvent
ItemType: TEXT
Rect: 13,14,141,36
TextFont: Geneva
TextSize: 12
Disabled: TRUE
Name: CurrentPeriod
LockText: FALSE
KeyFilter: bOnly4Chars
Balloon: Enter the name of the year (or other time period) you’d like to keep price information for here.
Script: --on closeField wdID,wdName,objNo,objName,objValue¬Global kMaxPeriods, gYears¬¬put TimePeriods_Text of window id wdID into currentText¬put TimePeriods_Selection of window id wdID into currentLine¬put line currentLine of currentText into oldYearText¬put objValue into newYearText¬put wdID into thisWindowName¬¬if oldYearText <> newYearText then¬ --put wsGet(wdID,"TimePeriods","Text") into currentText¬ if (word 1 of oldYearText = empty) and (word 1 of newYearText = empty) then¬ -- this was a new year but the user entered blanks. Just strip them out¬ put StripTrailingBlanks(currentText) into timePeriods¬ else¬ if word 1 of newYearText = empty then¬ -- Wiped out the line, but this year existed!¬ get WindowScript("Stop Alert","To remove a year from the list, select it and click “Close Year.”")¬ else¬ -- Existing year, just add it ¬ put newYearText into line currentLine of currentText¬ set TimePeriods_Text of window id thisWindowName to currentText¬ put currentText into gYears¬ ¬ -- Update the years in the various fields¬ if the short name of this bg = "Title" then send openbackground to this card¬ end if¬ end if¬ ¬ put (the number of lines of currentText >= kMaxPeriods) into newIsDisabled¬ set the properties of window id thisWindowName to "CurrentPeriod_Disabled:True" & return & "CurrentPeriod_Text:" & return & "i3_Disabled:" & newIsDisabled & return¬ ¬ put the number of lines of gYears into numYears¬ put line 1 of gYears into fld "Year 1 Title" of cd 1 of bg "Title"¬ put line 2 of gYears into fld "Year 2 Title" of cd 1 of bg "Title"¬ put line 3 of gYears into fld "Year 3 Title" of cd 1 of bg "Title"¬ put line 4 of gYears into fld "Year 4 Title" of cd 1 of bg "Title"¬ set the visible of fld "Current Year 2 Price" of cd 1 of bg "Title" to (numYears >= 2)¬ set the visible of fld "Current Year 3 Price" of cd 1 of bg "Title" to (numYears >= 3)¬ set the visible of fld "Current Year 4 Price" of cd 1 of bg "Title" to (numYears >= 4)¬end if¬--end closeField¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬
ItemType: LIST
Rect: 13,40,156,122
TextFont: Geneva
TextSize: 12
Name: TimePeriods
Logic: Single
Text: 1992¬1993¬1994¬1996
Balloon: This is the list of all the time periods for which you are keeping pricing information. A maximum of four years/periods can be tracked in this version of ComicBase.
Script: --on mouseUp wdID,wdName,objNo,objName,objValue¬put word 1 to 99 of wsGet(wdID,"TimePeriods","TextOfSelection") into selectedPeriod¬¬get timePeriods_Text of window wdName¬put ((the number of lines of it <= 1) or (selectedPeriod = empty)) into closeYearDisabled¬¬if selectedPeriod <> empty then¬ get "CurrentPeriod_Disabled:False" & return & "currentPeriod_Text:" & selectedPeriod & return & "CurrentPeriod_selection:0,99" & return¬else¬ get "CurrentPeriod_Disabled:True" & return & "CurrentPeriodTitle_Disabled:True" & return & "currentPeriod_Text:" & return¬end if¬set the properties of window wdName to it¬set i4_Disabled of window wdName to closeYearDisabled¬--end mouseUp¬
ItemType: PUSH
Rect: 174,40,281,60
AutoSize: FALSE
Disabled: TRUE
Name: New Year…
Balloon: Click here to add a new year (or other time period) you’d like to keep price information for.¬¬A maximum of four price periods can be kept. Once four have been entered, you’ll need to close a year before entering a new one.
Script: --on mouseUp wdID,wdName,objNo,objName,objValue¬Global gParamText1, gParamText2¬Global gProgressWindowName, maxStringWidth¬Global gYears, kMaxPeriods¬¬put wdID into thisWindowName¬put wsGet(wdID,"TimePeriods","Text") into timePeriods¬¬-- Figure out the next "logical" year to add¬put the number of lines of timePeriods into currentLine¬put line currentLine of timePeriods into lastExistingPeriod¬¬if lastExistingPeriod is a number then put lastExistingPeriod + 1 into suggestedNewPeriod¬else put empty into suggestedNewPeriod¬¬-- Ask user which year to add¬get WindowScript("Add Which Year", suggestedNewPeriod)¬if word 1 of line 1 of it = "Add" then¬ -- A year was entered¬ put line 2 of it into newYearText¬ ¬ -- See if the year already exists¬ if Find(timePeriods,newYearText,"Line","Begin") > 0 then¬ get WindowScript("Stop Alert","A year by that name already exists. Please choose another name for it.")¬ else¬ -- Ask user before adding the new year¬ put "The price data from " & lastExistingPeriod & " will be used as the basis for the new year’s data." into gParamText1¬ put "Would you like to save a copy of the ComicBase before adding the new year?" into gParamText2¬ ¬ put false into wasCancelled¬ get WindowScript("Save Alert")¬ if it <> empty then¬ -- Ask to make a backup first¬ if line 1 of it = "Save" then¬ ask file "Name of Backup File" with "ComicBase w/o " & newYearText & " data"¬ if it <> empty then DoSaveBackup it¬ else put true into wasCancelled¬ end if¬ ¬ if not wasCancelled then¬ -- Put up progress indicator¬ put "Adding " & newYearText into gProgressWindowName¬ get windowscript("Progress","Updating:","False")¬ send InitProgress to cd 3¬ ¬ -- Update each title¬ put the number of cards of bg "Title" into numTitles¬ repeat with X = 1 to numTitles¬ set cursor to busy¬ put the short id of cd X of bg "Title" into cardID¬ put fld "DisplayTitle" of cd ID cardID into theTitle¬ ¬ -- Update the progress indicator¬ set the properties of window gProgressWindowName to "CurrentTitle_Text:" & HCTruncString(theTitle,maxStringWidth,true,"Chicago",12,"Plain") & return & "ProgressBar_Value:" & trunc((x / numTitles) * 100) & return¬ ¬ -- Move a title’s information¬ set cursor to busy¬ put fld ("Price Year " & currentLine) of cd ID cardID into fld ("Price Year " & (currentLine + 1)) of cd ID cardID¬ end repeat¬ ¬ wsSend gProgressWindowName,"Close"¬ ¬ -- Update the screen now¬ put newYearText into line currentLine + 1 of timePeriods¬ put Trim(timePeriods) into timePeriods¬ wsSet thisWindowName,"TimePeriods","Text",timePeriods¬ put timePeriods into gYears¬ ¬ -- Update the years in the card fields¬ if the short name of this bg = "Title" then send openbackground to this card¬ ¬ wsSet thisWindowName,"3","Disabled", (the number of lines of gYears >= kMaxPeriods)¬ put the number of lines of gYears into numYears¬ put line 1 of gYears into fld "Year 1 Title" of cd 1 of bg "Title"¬ put line 2 of gYears into fld "Year 2 Title" of cd 1 of bg "Title"¬ put line 3 of gYears into fld "Year 3 Title" of cd 1 of bg "Title"¬ put line 4 of gYears into fld "Year 4 Title" of cd 1 of bg "Title"¬ set the visible of fld "Current Year 2 Price" of cd 1 of bg "Title" to (numYears >= 2)¬ set the visible of fld "Current Year 3 Price" of cd 1 of bg "Title" to (numYears >= 3)¬ set the visible of fld "Current Year 4 Price" of cd 1 of bg "Title" to (numYears >= 4)¬ ¬ end if -- Didn’t cancel out of save name dialog¬ end if -- Didn't cancel out of save/don't save copy dialog¬ end if -- See if year exists¬end if -- User specified a year¬--end mouseUp¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬
ItemType: PUSH
Rect: 174,66,281,86
Disabled: TRUE
Name: Close Year…
Balloon: Click here to remove the selected year’s price information from the list.¬¬You’ll be asked whether you would like to save a copy of the ComicBase first before deleting the year’s data.
Script: --on mouseUp wdID,wdName,objNo,objName,objValue¬Global kMaxPeriods, gYears, gParamText1, gParamText2¬Global gProgressWindowName, maxStringWidth¬¬put wdID into yearSetupWindowID¬¬put TimePeriods_Selection of window id yearSetupWindowID into currentLine¬put TimePeriods_Text of window id yearSetupWindowID into currentText¬put line currentLine of currentText into currentYear¬put the number of lines of currentText into numYears¬¬put "Closing " & currentYear & " will remove all its pricing data from the ComicBase." into gParamText1¬put "Would you like to save a copy of the ComicBase before doing this?" into gParamText2¬¬put false into wasCancelled¬get WindowScript("Save Alert")¬if it <> empty then¬ if line 1 of it = "Save" then¬ -- Make a backup first¬ ask file "Name of Backup File" with "ComicBase with " & currentYear & " data"¬ if it <> empty then DoSaveBackup it ¬ else put true into wasCancelled¬ end if¬ ¬ if not wasCancelled then¬ -- Now close out the year¬ -- Put up progress indicator¬ put "Closing " & currentYear into gProgressWindowName¬ get windowscript("Progress","Updating:","False")¬ send InitProgress to cd 3¬ ¬ put the number of cards of bg "Title" into numTitles¬ ¬ put (currentLine < numYears) into mustShuffle¬ ¬ repeat with X = 1 to numTitles¬ set cursor to busy¬ put the short id of cd X of bg "Title" into cardID¬ put fld "DisplayTitle" of cd ID cardID into theTitle¬ ¬ -- Update the progress indicator¬ set the properties of window gProgressWindowName to "CurrentTitle_Text:" & HCTruncString(theTitle,maxStringWidth,true,"Chicago",12,"Plain") & return & "ProgressBar_Value:" & trunc((x / numTitles) * 100) & return¬ -- Move a title’s information¬ if mustShuffle then¬ repeat with shuffleYear = currentLine + 1 to numYears¬ set cursor to busy¬ put fld ("Price Year " & shuffleYear) of cd ID cardID into fld ("Price Year " & (shuffleYear - 1)) of cd ID cardID¬ end repeat¬ end if¬ ¬ -- Clear out that title’s data for the year being closed¬ -- (which is now last, since shuffling)¬ put empty into fld ("Price Year " & numYears) of cd ID cardID¬ end repeat¬ ¬ -- Update the screen now¬ delete line currentLine of currentText¬ put currentText into gYears¬ ¬ set the properties of window id yearSetupWindowID to "CurrentPeriod_Disabled:True" & return & "currentPeriod_Text:" & return & "i4_Disabled:True" & return & "i3_Disabled:False" & return ¬ set TimePeriods_Text of window id yearSetupWindowID to gYears¬ ¬ if the short name of this bg = "Title" then send openbackground to this card¬ wsSend gProgressWindowName,"Close"¬ ¬ put the number of lines of gYears into numYears¬ put line 1 of gYears into fld "Year 1 Title" of cd 1 of bg "Title"¬ put line 2 of gYears into fld "Year 2 Title" of cd 1 of bg "Title"¬ put line 3 of gYears into fld "Year 3 Title" of cd 1 of bg "Title"¬ put line 4 of gYears into fld "Year 4 Title" of cd 1 of bg "Title"¬ set the visible of fld "Current Year 2 Price" of cd 1 of bg "Title" to (numYears >= 2)¬ set the visible of fld "Current Year 3 Price" of cd 1 of bg "Title" to (numYears >= 3)¬ set the visible of fld "Current Year 4 Price" of cd 1 of bg "Title" to (numYears >= 4)¬ end if¬end if¬--end mouseUp¬¬¬